using System;
using System.Collections.Generic;
using System.Text;

namespace cuberga.GA
{
    public abstract class Genotype
    {
        private double _fitness = 1; //double.NaN;

        public abstract void FromStructure(object Struct);
        public abstract object ToStructure();

        public double GetFitness()
        {
            if (double.IsNaN(_fitness))
            {
                throw new SystemException("Genotype hasn't been evaluated yet!");
            }

            return _fitness;
        }

        public void SetFitness(double newFitness)
        {
            _fitness = newFitness;
        }

        public Genotype Clone()
        {
            Genotype result = (Genotype) this.MemberwiseClone();
            result.FromStructure(this.ToStructure());
            return result;
        }
    }
}
